import { fileUploadControllerUploadFile } from "@/app/servers/api/fileUpload";
import { NextRequest } from "next/server";

export const POST = async (request: NextRequest) => {
  const formData = await request.formData();
  const { data } = await fileUploadControllerUploadFile({
    data: formData,
    next: {
      headers: request.headers,
      cookies: request.cookies,
    },
  });
  return new Response(
    JSON.stringify({
      errno: 0, // 注意：值是数字，不能是字符串
      data: {
        url: data.href, // 图片 src ，必须
        alt: data.name, // 图片描述文字，非必须
        href: data.href, // 图片的链接，非必须
      },
    })
  );
};
